<template>
  <a-modal :title="title" :visible="visible" @cancel="handleCancel" :destroyOnClose="true">
    <a-form-model ref="form" :model="queryParam">
      <a-form-model-item label="附件" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="fileNameList">
        <!-- <NKUpload ref="fileUpload" :fileid="'file'" @uploadFile="handleFileUploaded"></NKUpload> -->
        <RuleUpload
          ref="fileUpload"
          :fileid="queryParam.fid"
          :isShow="isShow"
          @uploadFile="handleSubmit"
          :disDel="true"
        ></RuleUpload>
      </a-form-model-item>
    </a-form-model>

    <!-- <template v-if="title != '详情'" slot="footer">
      <a-button @click="handleCancel">取消</a-button>
      <a-button type="primary" @click="saveData(0)">保存</a-button>
      <a-button type="primary" @click="saveData(1)">提交</a-button>
    </template> -->

    <template slot="footer">
      <a-button @click="handleCancel">关闭</a-button>
    </template>
  </a-modal>
</template>

<script>
import moment from 'moment'
import { httpAction, getAction, postAction, deleteAction } from '@/api/manage'
// import NKUpload from './components/NKUpload.vue'
import RuleUpload from '../../components/RuleUpload.vue'
export default {
  name: 'FileModel',
  components: { RuleUpload },
  data() {
    return {
      title: '查看文件',
      queryParam: {},
      visible: false,
      isShow: true,
      disableSubmit: true,
      fileData: [],
      labelCol: {
        xs: { span: 24 },
        sm: { span: 5 },
      },
      wrapperCol: {
        xs: { span: 24 },
        sm: { span: 16 },
      },
      approverList: '',
      url: {
        file:'/incon/inconReviewPlan/queryFileList'
      },
    }
  },
  created() {},
  methods: {
    saveData(type) {
      console.log(type, 'type')
      this.queryParam.submitFlag = type
      // debugger
      this.$refs.fileUpload.saveFile()
    },
    handleSubmit(id) {
      // console.log(this.queryParam, 'query')
      this.$refs.form.validate((valid) => {
        if (valid) {
          this.visible = false
          let params = {
            ...this.queryParam,
            fid: id,
          }
          this.$emit('openModelView', params)
          this.queryParam = {
            year: '',
          }
        } else {
          return false
        }
      })
    },
    handleCancel(e) {
      this.queryParam = {
        year: '',
      }
      this.visible = false
    },
    moment,
    // 得到年份选择器的值
    handlePanelChange(value) {
      this.queryParam.year = moment(value).format('YYYY')
      this.yearPickShow = false
      this.$refs.form.validateField('year', (error) => {
        console.log(error)
      })
    },
    async getFileList(record,type) {
      // ${record.status}
      const data = await getAction(`${this.url.file}?planId=${record.id}&fileType=${type}`)
      if (+data.code == 200) {
        this.$refs.fileUpload.setFile(data.result.records)
      }
    },
    // 弹出日历和关闭日历的回调
    handleOpenChange(status) {
      this.yearPickShow = status
    },
    look(record,type) {
      // console.log(record, 'record')
      this.getFileList(record,type)
      this.visible = true
    },
  },
}
</script>

<style scoped>
</style>
